package com.example.demo.service;

import com.example.demo.mapper.CustomerMapper;
import com.example.demo.pojo.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerService {
    @Autowired
    private CustomerMapper customerMapper;

    public Customer getCustByCustNum() {
        return customerMapper.getCustByCustNum();
    }


    public int updateCustByCustNum(String custNum, String username) {
        return customerMapper.updateCustByCustNum(custNum,username);
    }

    public int addCustByUser(String custName, String username, String custNum, int custPhone, String sex, int roomID, int custState) {
        return customerMapper.addCustByUser(custName,username,custNum,custPhone,sex,roomID,custState);
    }

    //管理员登记，可以没有username
    public int addCust(String custName, String custNum, int custPhone, String sex, int roomID, int custState) {
        return customerMapper.addCust(custName,custNum,custPhone,sex,roomID,custState);
    }

    public int getCustCount(){
        return customerMapper.getCustCount();
    }

    public int getlivingCount(){
        return customerMapper.getlivingCount();
    }

    public int updateCustUserNameByUserID(int userID, String username) {
        return customerMapper.updateCustUserNameByUserID(userID,username);
    }

    public List<Customer> getCustAll() {
        return customerMapper.getCustAll();
    }

    public int deleteCustByCustID(int custID) {
        return customerMapper.deleteCustByCustID(custID);
    }

    public int updateCustNameByCustID(int custID, String custName, String username, String custNum, int custPhone, String sex, int roomID, int custState) {
        return customerMapper.updateCustNameByCustID(custID,custName,username,custNum,custPhone,sex,roomID,custState);
    }

    public Customer findByUID(int uID){
        return customerMapper.findByUID(uID);
    }

    public int addCustMsg(String custName, int uID, String custNum, String custPhone, String sex){
        return customerMapper.addCustMsg(custName, uID, custNum,custPhone, sex);
    }
    public int update(Customer customer){
        return customerMapper.update(customer);
    }

    public String getcustNameByNum(String custNum) {
        return customerMapper.getcustNameByNum(custNum);
    }

    public int getcustPhoneByNum(String custNum) {
        return customerMapper.getcustPhoneByNum(custNum);
    }

    public int updateCustState(String custNum2, String roomID, int custState) {
        return customerMapper.updateCustState(custNum2,roomID,custState);
    }

    public void updateCustStateBy(String custNum, int custState) {
        customerMapper.updateCustStateBy(custNum,custState);
    }

    public Customer getCustByUid(String uid) {
       return customerMapper.getCustByUid(uid);
    }

    public int updateCustByCustID(String custID, String custName, String custNum, String custPhone, String sex) {
        return customerMapper.updateCustByCustID(custID,custName,custNum,custPhone,sex);
    }

    public int updateCustUidByuid(String uid) {
        return customerMapper.updateCustUidByuid(uid);
    }

    public String checkCustNumIfexit(String custNum) {
        return customerMapper.checkCustNumIfexit(custNum);
    }

    public String checkCustNumByCustID(String custNum, int custID) {
        return customerMapper.checkCustNumByCustID(custNum,custID);
    }
}

